package booksys.login;

import booksys.common.Utils;
import org.apache.ibatis.session.SqlSession;

public class LoginService {
    private booksys.common.Utils Utils;

    public boolean checkLogin(LoginDto dto) {

        SqlSession sqlSession = Utils.openSession();

        try{
            LoginDao dao = sqlSession.getMapper(LoginDao.class);
            int count = dao.findTeacherCountByIdAndPwd(dto);//select count(t_id) from t_teacher where t_id = 'xxx' and t_pwd = 'cccc'

            sqlSession.commit();

            return count > 0;
        }catch(Exception e){
            sqlSession.rollback();
            throw new RuntimeException(e);
        }finally{
            sqlSession.close();
        }


    }
}
